﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections;

public enum NewsType { Default=0,news = 1, popular = 2, Wiki = 3, MedicalCenters = 4, MedicalTourism = 5, aboutUS = 6,
    deadSea = 7 ,hotels=8,Diagnostic=9,Contacts=10};
/// <summary>
/// Summary description for Articles
/// </summary>
public class Articles
{
	public Articles()
	{
	}

    public static ArticleItem GetArticleByName(string sName)
    {
        Dal.arParams.Clear();
        Dal.arParams.Add(sName);
        return new ArticleItem(Dal.ExecuteDBspDS("usp_GetArticleByCPageName", Dal.arParams));
        
    }

    public static ArticleItem GetArticleCatID(int iCatID)
    {
        Dal.arParams.Clear();
        Dal.arParams.Add(iCatID);

        return new ArticleItem(Dal.ExecuteDBspDS("usp_GetArticleByCatID", Dal.arParams));

    }
}

[Serializable]
public class ArticleItem
{
    // articleId
    //imgId
    //catId
    //number

    //inSearch
    //isPopular
    //articleVizible

    //articleName
    //articleFragment
    //articleContext
    //articleAddDate

    private long _articleId;
    private string _sImgName;
    private int _catId;
    private int _number;
    private bool _isDateVisible;
    //' Private _articleVizible As Boolean
    private bool _isPopular;
    private string _articleContext;
    private string _articleName;
    private string _articleFragment;

    private DateTime _articleAddDate;
    public string BrowserTitle = string.Empty;
    public string imgPreview = string.Empty;
    public DataTable _tags;
    // for admin 
    //articleAddDate
    // articleDateModifierd
    //ArticleAdminState

    #region Properties
    public String articleFragment
    {
        get
        {
            return _articleFragment;
        }
        set
        {
            _articleFragment = value;
        }
    }

    public String articleContext
    {
        get
        {
            return _articleContext;
        }
        set
        {
            _articleContext = value;
        }
    }

    public String articleName
    {
        get
        {
            return _articleName;
        }
        set
        {
            _articleName = value;
        }
    }

    public Boolean isPopular
    {
        get
        {
            return _isPopular;
        }
        set
        {
            _isPopular = value;
        }
    }

    public Boolean isDateVisible
    {
        get
        {
            return _isDateVisible;
        }
        set
        {
            _isDateVisible = value;
        }
    }

    public int number
    {
        get
        {
            return _number;
        }
        set
        {
            _number = value;
        }
    }

    public long articleId
    {
        get
        {
            return _articleId;
        }
        set
        {
            _articleId = value;
        }
    }

    public int catId
    {
        get
        {
            return _catId;
        }
        set
        {
            _catId = value;
        }
    }
    public string sImage
    {
        get
        {
            return "picture_library/" + this._sImgName;
        }
    }

    public DateTime articleAddDate
    {
        get
        {
            return _articleAddDate;
        }
        set
        {
            _articleAddDate = value;
        }
    }
    #endregion

    public ArticleItem(DataSet DS)
    {
        if (DS != null)
        {
            if (DS.Tables.Count > 0)
            {
                if (DS.Tables[0].Rows.Count > 0)
                {
                    this._articleId = Convert.ToInt64(DS.Tables[0].Rows[0]["ArticleID"]);
                    this.BrowserTitle = DS.Tables[0].Rows[0]["BrowserTitle"].ToString();
                    this._articleName = DS.Tables[0].Rows[0]["Title"].ToString();
                    this._articleFragment = DS.Tables[0].Rows[0]["SubTitle"].ToString();
                    this._articleContext = DS.Tables[0].Rows[0]["Article"].ToString();
                    this._articleAddDate = DateTime.Parse(DS.Tables[0].Rows[0]["publishDate"].ToString());
                    this._catId = Convert.ToInt32(DS.Tables[0].Rows[0]["catId"]);
                    this._sImgName = DS.Tables[0].Rows[0]["img630x200"].ToString();
                    _isPopular = Convert.ToBoolean(DS.Tables[0].Rows[0]["ispopular"]);
                    if (_sImgName.Length == 0)
                    {
                        _sImgName = "630x200.jpg";
                    }
                    this._isDateVisible = Convert.ToBoolean(DS.Tables[0].Rows[0]["isDateVisible"]);
                    try
                    {
                        this.imgPreview = DS.Tables[0].Rows[0]["img170x148"].ToString();
                    }
                    catch { }
                }
                if (DS.Tables.Count > 1)
                    if (DS.Tables[1].Rows.Count > 0)
                    {
                        _tags = DS.Tables[1];
                    }
            }
        }
    }
}

